package com.kaifamiao.base.Demo20210918;

import java.util.Scanner;

/**
 * @author lucien-ma
 * @date 2021/9/18
 * @apiNote
 */
public class Demo01 {

    public static void main(String[] args) {
        String oct = toOctal(input());
        System.out.println(oct);
    }

    public static String toOctal(int dec) {
        // 传进来的十进制数
        int decTemp = dec;
        // 转换的进制
        int divisor = 8;
        StringBuilder oct = new StringBuilder();
        do {
            // 余数
            int remainder = decTemp % divisor;
            // 解析余数
            oct.append(remainder);
            // 计算商
            decTemp = decTemp / divisor;
        } while (decTemp != 0);
        return oct.reverse().toString();
    }

    public static int input() {
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入一个十进制整数：");
        return scanner.nextInt();
    }

}
